home *** CD-ROM | disk | FTP | other *** search
- #include "HEADERS.h"
- #include "srgplocal.h"
-
- /** INFORMATION ABOUT THE LOW-LEVEL ECHOING DRIVERS
-
- SRGP__initEchoModule ()
- Must be called once, during initialization.
- The echo-attribute globals must have already been given
- default initial values!
-
- SRGP__updateLocatorRubberAnchor ()
- Acesses current locator rubber anchor from globals.
- May be called whether rubber echo is active or not.
-
- SRGP__enableLocatorRubberEcho ()
- Accesses current locator measure info from global variables.
- May be called carelessly:
- 1) Will not re-enable if already enabled
- 2) Will refuse to enable echo for a device that is:
- A) not active currently, and
- B) not in a state for which echo is desired
-
- SRGP__updateLocatorRubberEcho ()
- Accesses current locator measure info from global variables.
- May be called carelessly:
- Will not update if device is currently disabled.
-
- SRGP__disableLocatorRubberEcho ()
- May be called carelessly:
- Will not re-disable if already disabled
-
-
- SRGP__updateLocatorCursorShape ()
- May be called whether or not the cursor echo is active.
-
- SRGP__enableLocatorCursorEcho ()
- SRGP__disableLocatorCursorEcho ()
- May be called carelessly.
-
- SRGP__updateRawCursorPosition ()
- Accesses cur_locator_measure from global variables.
- Informs the underlying graphics package of the desired "cursor warp".
- Automatically updates any type of locator echo: cursor or rubber.
-
-
- SRGP__updateKeyboardEchoAttributes ()
- May be called whether or not key echo is active.
- Obtains attributes from global variables.
-
- SRGP__enableKeyboardEcho ()
- SRGP__updateKeyboardEcho ()
- SRGP__disableKeyboardEcho ()
- Similar to above: may be called carelessly.
-
- **/
-
-
- /* FOR LOCATOR ECHO */
-
-
- static locator_echo_mode = NO_ECHO;
- static int echo_rubber_x; /* rubber echo X anchor position */
- static int echo_rubber_y; /* rubber echo Y anchor position */
-
- /* FOR KEYBOARD ECHO */
- static boolean keyboard_echo_is_active=FALSE;
- static int echo_keybd_x = 0; /* X position */
- static int echo_keybd_y = 0; /* Y position */
- static int echo_keybd_w = 0; /* width of current echo */
- static int echo_keybd_h = 0; /* height of current echo */
-
- GrTextOption srgp__grx_keyboard_echo_textopt;
-
- void SRGP__initEchoModule(void)
- {
- /* INITIALIZE KEYBOARD: font, color, origin */
- SRGP__updateKeyboardEchoAttributes();
-
- /* DEFAULT LOCATOR-ECHO RUBBER ANCHOR (same as keyboard echo) */
- echo_rubber_x = echo_keybd_x;
- echo_rubber_y = echo_keybd_y;
- }
-
- static void cursorecho(int mode)
- {
- switch(mode) {
- case NO_ECHO:
- if(locator_echo_mode != NO_ECHO) MouseEraseCursor();
- locator_echo_mode = NO_ECHO;
- return;
- case CURSOR:
- MouseSetCursorMode(M_CUR_NORMAL);
- break;
- case RUBBER_LINE:
- MouseSetCursorMode(M_CUR_LINE,
- echo_rubber_x,
- echo_rubber_y,
- COLORINDEX(srgp__canvasTable[0].attributes.color) ^
- COLORINDEX(srgp__canvasTable[0].attributes.background_color)
- );
- break;
- case RUBBER_RECT:
- MouseSetCursorMode(M_CUR_RUBBER,
- echo_rubber_x,
- echo_rubber_y,
- COLORINDEX(srgp__canvasTable[0].attributes.color) ^
- COLORINDEX(srgp__canvasTable[0].attributes.background_color)
- );
- break;
- }
- if(locator_echo_mode == NO_ECHO) MouseDisplayCursor();
- locator_echo_mode = mode;
- }
-
- void SRGP__enableLocatorRubberEcho(void)
- {
- if(srgp__cur_mode[LOCATOR] == INACTIVE) return;
- if(srgp__cur_locator_echo_type <= CURSOR) return;
- echo_rubber_x = srgp__cur_locator_echo_anchor.x;
- echo_rubber_y = SCREENFIXED(srgp__cur_locator_echo_anchor.y);
- cursorecho(srgp__cur_locator_echo_type);
- }
-
- void SRGP__disableLocatorRubberEcho(void)
- {
- if(srgp__cur_mode[LOCATOR] == INACTIVE) return;
- if(srgp__cur_locator_echo_type <= CURSOR) return;
- cursorecho(CURSOR);
- }
-
- void SRGP__updateLocatorRubberEcho(void)
- {
- return; /* DUMMY HERE !!! */
- }
-
- void SRGP__updateLocatorRubberAnchor(void)
- {
- echo_rubber_x = srgp__cur_locator_echo_anchor.x;
- echo_rubber_y = SCREENFIXED(srgp__cur_locator_echo_anchor.y);
- if(srgp__cur_mode[LOCATOR] == INACTIVE) return;
- if(srgp__cur_locator_echo_type <= CURSOR) return;
- cursorecho(locator_echo_mode);
- }
-
- void SRGP__enableLocatorCursorEcho(void)
- {
- if(srgp__cur_mode[LOCATOR] == INACTIVE) return;
- if(srgp__cur_locator_echo_type < CURSOR) return;
- cursorecho(srgp__cur_locator_echo_type);
- }
-
- void SRGP__disableLocatorCursorEcho(void)
- {
- if(srgp__cur_mode[LOCATOR] == INACTIVE) return;
- cursorecho(NO_ECHO);
- }
-
- void SRGP__updateLocatorCursorShape(void)
- {
- MouseSetCursor(srgp__cursorTable[srgp__cur_cursor]);
- }
-
- /** KEYBOARD ECHO **/
-
- static void DrawText(void)
- {
- char *p = srgp__cur_keyboard_measure.buffer;
- int len = srgp__cur_keyboard_measure_length;
- int www = GrStringWidth(p,len,&srgp__grx_keyboard_echo_textopt);
-
- GrDrawString(p,len,echo_keybd_x,echo_keybd_y,&srgp__grx_keyboard_echo_textopt);
- if(www < echo_keybd_w) GrFilledBox(echo_keybd_x+www,
- echo_keybd_y,
- echo_keybd_x+echo_keybd_w-1,
- echo_keybd_y+echo_keybd_h-1,
- srgp__grx_keyboard_echo_textopt.txo_bgcolor.v
- );
- echo_keybd_w = www;
- }
-
- static void EraseText(void)
- {
- if(echo_keybd_w > 0) GrFilledBox(echo_keybd_x,
- echo_keybd_y,
- echo_keybd_x+echo_keybd_w-1,
- echo_keybd_y+echo_keybd_h-1,
- srgp__grx_keyboard_echo_textopt.txo_bgcolor.v
- );
- echo_keybd_w = 0;
- }
-
- void SRGP__enableKeyboardEcho(void)
- {
- if(!keyboard_echo_is_active) {
- if(srgp__cur_mode[KEYBOARD] != INACTIVE) {
- if(srgp__cur_keyboard_processing_mode == EDIT) {
- keyboard_echo_is_active = TRUE;
- DrawText();
- }
- }
- }
- }
-
- void SRGP__disableKeyboardEcho(void)
- {
- if(keyboard_echo_is_active) {
- EraseText();
- keyboard_echo_is_active = FALSE;
- }
- }
-
- void SRGP__updateKeyboardEcho(void)
- {
- if(keyboard_echo_is_active) DrawText();
- }
-
- void SRGP__updateKeyboardEchoAttributes(void)
- {
- if(keyboard_echo_is_active) EraseText();
- memset(&srgp__grx_keyboard_echo_textopt,0,sizeof(srgp__grx_keyboard_echo_textopt));
- srgp__grx_keyboard_echo_textopt.txo_font =
- srgp__fontTable[srgp__cur_keyboard_echo_font];
- srgp__grx_keyboard_echo_textopt.txo_fgcolor.v =
- COLORINDEX(srgp__cur_keyboard_echo_color);
- srgp__grx_keyboard_echo_textopt.txo_bgcolor.v =
- COLORINDEX(srgp__canvasTable[0].attributes.background_color);
- srgp__grx_keyboard_echo_textopt.txo_xmag = 1;
- srgp__grx_keyboard_echo_textopt.txo_ymag = 1;
- echo_keybd_h = GrFontHeight(&srgp__grx_keyboard_echo_textopt);
- echo_keybd_x = srgp__cur_keyboard_echo_origin.x;
- echo_keybd_y = SCREENFIXED(srgp__cur_keyboard_echo_origin.y) - ((echo_keybd_h * 5) / 7);
- if(keyboard_echo_is_active) DrawText();
- }
-
-